/**
 * 
 */
package com.sys.console.business.impl;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import com.sys.console.business.SysEmailConfigService;
import com.sys.console.mapper.SysEmailConfigMapper;
import com.sys.console.pojo.SysEmailConfig;

/**
 * @author zxp
 *
 */
@Service
public class SysEmailConfigServiceImpl implements SysEmailConfigService {

	@Autowired SysEmailConfigMapper sysEmailConfigMapper;
	@Override
	public SysEmailConfig selectByPrimaryKey(String id,HttpServletRequest request) throws Exception {
		//SysEmailConfig sysmon = (SysEmailConfig) request.getSession().getAttribute("sys_email_config_session");
		//if(sysmon == null || !StringUtils.hasText(sysmon.getId())){
			SysEmailConfig sysmon = sysEmailConfigMapper.selectByPrimaryKey(id);
			//request.getSession().setAttribute("sys_email_config_session", sysmon);
	//	}
		return sysmon;
	}
	@Override
	public int saveOrUpdate(SysEmailConfig record,HttpServletRequest request) throws Exception {
		int suc = 0;
		if(record!=null && StringUtils.hasText(record.getId())){
			suc = sysEmailConfigMapper.updateByPrimaryKeySelective(record);
//			if(suc >0){
//				
//				request.getSession().setAttribute("sys_email_config_session", record);
//			}
			return suc;
		}
		suc = sysEmailConfigMapper.insert(record);
//		if(suc >0){
//			request.getSession().setAttribute("sys_email_config_session", record);
//		}
		return suc;
	}


}
